#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int
main()
{
	char c;
	unsigned int frequency[CHAR_MAX], max=0, i=0;
	freopen("chart.in", "r", stdin);
	freopen("chart.out", "w", stdout);
	for (i = 0; i < CHAR_MAX ; ++i) /* resetting memory */
		frequency[i] = 0;

	while (c = getchar(), c != EOF) { /* parsing text */
		if (c == '\n' || c == ' ')
			continue;
		++frequency[c];
	}

	for (i = 0; i < CHAR_MAX; ++i) /* finding max frequency */
		if (frequency[i] > max)
			max = frequency[i];

	for ( ; max > 0 ; --max) {
		for (i = 0; i < CHAR_MAX ; ++i) {
			if (frequency[i] >= max)
				printf("#");
			else if (frequency[i] > 0)
				printf(" ");
		}
		putchar('\n');
	}

	for (i = 1 ; i < CHAR_MAX ; ++i)
		if (frequency[i] > 0)
			putchar(i);

	putchar('\n');
	return 0;
}
